<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
<title>成绩列表</title>
<c:import url="/WEB-INF/jsp/head.jsp" />
<c:import url="/WEB-INF/jsp/plugin/loading.jsp" />
<script type="text/javascript" src="static/js/bootbox.4.4.0.min.js"></script>
<script type="text/javascript" src="static/js/moment.min.js"></script>
<c:import url="/WEB-INF/jsp/plugin/vue.jsp" />
<c:import url="/WEB-INF/jsp/plugin/vue-paging.jsp" />
<c:import url="/WEB-INF/jsp/plugin/vue-modal.jsp" />
<c:import url="/WEB-INF/jsp/plugin/datetimepicker.jsp" />
<script type="text/javascript" src="static/js/score/list.js"></script>
</head>
<body>
	<div id="app" v-cloak class="default-theme container-fluid iframe">
		<div class="col-md-12">
			<div class="condition panel panel-default">
				<div class="panel-heading">搜索条件</div>
				<div class="panel-body">
					<div class="form-inline">
						<div class="form-group">
							<label for="id">学生学号:</label>
							<input type="text" class="form-control" v-model.trim="condition.studentId"/>
						</div>
						<div class="form-group">
							<label for="id">班级:</label>
							<input type="text" class="form-control" v-model.trim="condition.className" style="width: 10em" 
								@click="showClass=true"/>
						</div>
						<div class="form-group">
							<label for="id">考试类型:</label>
							<select class="form-control" v-model.trim="condition.type">
								<option :value="null">所有</option>
								<option v-for="type in types" :value="type.value">{{ type.name }}</option>
							</select>
						</div>
						<div class="form-group">
							<label for="id">考试方式:</label>
							<select class="form-control" v-model.trim="condition.pattern">
								<option :value="null">所有</option>
								<option v-for="pattern in patterns" :value="pattern.value">{{ pattern.name }}</option>
							</select>
						</div>
						<br/>
						<div class="form-group">
							<label for="startDate">考试时间:</label>
							<div class="input-group date">
								<input type="text" name="startDate"
									class="form-control text-center date" readonly="readonly"
									placeholder="起始时间" />
								<span class="input-group-addon">至</span>
								<input type="text" name="endDate"
									class="form-control text-center date" readonly="readonly"
									placeholder="结束时间" />
							</div>
						</div>
						<div class="form-group">
							<label for="startDate">考试成绩:</label>
							<div class="input-group date">
								<input type="number" name="minPoint" v-model.trim="condition.minPoint"
								    min="1" max="200" step="0.5" class="form-control text-center" />
								<span class="input-group-addon">至</span>
								<input type="number" name="maxPoint" v-model.trim="condition.maxPoint"
								    min="1" max="200" step="0.5" class="form-control text-center" />
							</div>
                        </div>
                        <fieldset>
                            <div class="form-group">
                                <button class="btn btn-default" @click="serach">
                                    <span class="glyphicon glyphicon-search">搜索</span>
                                </button>
                            </div>
                            <div class="form-group">
                                <button class="btn btn-info" @click="open(0)">
                                    <span class="glyphicon glyphicon-plus">新增</span>
                                </button>
                            </div>
                            <div class="form-group">
                                <button class="btn btn-default" @click="exportExcel">
                                    <span class="glyphicon glyphicon-save">导出</span>
                                </button>
                            </div>
                        </fieldset>
					</div>
				</div>
			</div>
		</div>
		<div class="col-md-12">
			<table class="table table-hover table-border">
				<thead>
					<tr>
						<th style="min-width: 6rem">学生姓名</th>
                        <th style="min-width: 6rem">班级</th>
						<th style="min-width: 6rem">考试日期</th>
						<th style="min-width: 6rem">考试内容</th>
						<th>考试类型</th>
						<th>考试方式</th>
						<th>分数</th>
						<th>总分</th>
						<th style="min-width: 20rem; width: 20rem">操作</th>
					</tr>
				</thead>
				<tbody>
					<tr v-if="items.length === 0" align="center">
						<td colspan="9">没有查询到数据</td>
					</tr>
					<tr v-for="item in items">
						<td>
							<a @click="openTab('score/student/' + item.student.id + '/dashboard', '学生成绩概览')">{{item.student.name}}</a>
						</td>
                        <td>
                        	<a @click="openTab('score/class/' + item.student.classes.name + '/dashboard', '班级成绩概览')">{{item.student.classes.name}}</a>
                        </td>
						<td>{{ formatDate(item.date) }}</td>
						<td>{{item.content}}</td>
						<td>{{item.type.name}}</td>
						<td>{{item.pattern.name}}</td>
						<td>{{item.point}}</td>
						<td>{{item.totalPoint}}</td>
						<td>
							<button type="button" class="btn btn-info btn-sm"
								@click="open(1, item.id)">
								<span class="glyphicon glyphicon-pencil">编辑</span>
							</button>
                            <button type="button" class="btn btn-danger btn-sm"
                                @click="del(item.id)">
								<span class="glyphicon glyphicon-trash">删除</span>
							</button>
						</td>
					</tr>
				</tbody>
			</table>
			<paging :page="page" @go="serach"></paging>
		</div>
		<modal v-if="show" @close="show=false">
			<fieldset slot="body">
				<div class="form-group">
					<label class="col-sm-2 control-label" v-if="modalType!==0">成绩编号</label>
                    <div class="col-sm-4" v-if="modalType!==0">
                        <input type="text" class="form-control" v-model.trim="item.id" :readonly="modalType!==0"/>
                    </div>
                   	<label class="col-sm-2 control-label">学生学号</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="studentId"
                            v-validate="'required'" v-model.trim="item.student.id" :readonly="modalType!==0"/>
                    	<span v-show="errors.has('studentId')" class="text-danger">学号不能为空</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">考试内容</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" v-model.trim="item.content"/>
                    </div>
                    <label class="col-sm-2 control-label">考试时间</label>
                    <div class="col-sm-4">
                        <input type="text" name="scoreDate" v-validate="'required'" class="form-control datetimepicker date" readonly="readonly"/>
                        <span v-show="errors.has('scoreDate')" class="text-danger">考试时间不能为空</span>
                    </div>
                </div>
				<div class="form-group">
                    <label class="col-sm-2 control-label">考试类型</label>
                    <div class="col-sm-4">
                        <select class="form-control" v-model.trim="item.type.value" name="typeValue"
                            v-validate="'required'">
                    		<option disabled :value="null">请选择</option>
							<option v-for="type in types" :value="type.value">{{ type.name }}</option>
                        </select>
                        <span v-show="errors.has('typeValue')" class="text-danger">考试类型不能为空</span>
                    </div>
                    <label class="col-sm-2 control-label">考试方式</label>
                    <div class="col-sm-4">
                        <select class="form-control" v-model.trim="item.pattern.value" name="patternValue"
                            v-validate="'required'">
                        	<option disabled :value="null">请选择</option>
							<option v-for="pattern in patterns" :value="pattern.value">{{ pattern.name }}</option>
                        </select>
                        <span v-show="errors.has('patternValue')" class="text-danger">考试方式不能为空</span>
                    </div>
                </div>
				<div class="form-group">
                    <label class="col-sm-2 control-label">考试分数</label>
                    <div class="col-sm-4">
                        <input type="number" class="form-control" min="1" max="200" step="0.5" v-model.number="item.point"
                            name="point" v-validate="'required'" />
                        <span v-show="errors.has('point')" class="text-danger">考试分数不能为空</span>
                    </div>
                    <label class="col-sm-2 control-label">及格分数</label>
                    <div class="col-sm-4">
                        <input type="number" class="form-control" min="1" max="200" step="0.5" v-model.trim="item.passScore"
                            name="passScore" v-validate="'required'" />
                        <span v-show="errors.has('passScore')" class="text-danger">及格分数不能为空</span>
                    </div>
                </div>
				<div class="form-group">
                    <label class="col-sm-2 control-label">考试总分</label>
                    <div class="col-sm-4">
                        <input type="number" class="form-control" min="1" max="200" step="0.5" v-model.number="item.totalScore"
                            name="totalScore" v-validate="'required'"/>
                        <span v-show="errors.has('totalScore')" class="text-danger">考试总分不能为空</span>
                    </div>
                </div>
			</fieldset>
			<div slot="option">
				<button type="button" class="btn btn-info" v-if="modalType==0" @click="add">
					<span class="glyphicon glyphicon-plus">新增</span>
				</button>
				<button type="button" class="btn btn-info" v-if="modalType==1" @click="edit">
					<span class="glyphicon glyphicon-pencil">编辑</span>
				</button>
				<button type="button" class="btn btn-default" @click="show=false">
					<span class="glyphicon glyphicon-remove">关闭</span>
				</button>
			</div>
		</modal>
		<modal v-if="selectStu" @close="selectStu=falses">
		<fieldset slot="body">
			<div class="form-group">
			
				<label class="col-sm-2 control-label">学生学号</label>
				<div class="col-sm-4">
					<input type="text" class="form-control" name="studentId"
						v-model.trim="item.student.id" :readonly="modalType!==0" />
				</div>
			</div>

		</fieldset>
		<div slot="option">
			<button type="button" class="btn btn-default"
				@click="selectStu=falses">
				<span class="glyphicon glyphicon-remove">关闭</span>
			</button>
		</div>
		</modal>
	</div>
</body>
</html>